package pkg

import (
	"time"

	"github.com/dgrijalva/jwt-go"
)

const (
	APP_KEY = "b5bq9vt87eufiazuoge8wfrsuvbtwqe0i5thfiu"
)

func TokenHandler(user string) (string, error) {
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
		"user": user,
		"exp":  time.Now().Add(time.Hour * time.Duration(2)).Unix(),
		"iat":  time.Now().Unix(),
	})
	tokenString, err := token.SignedString([]byte(APP_KEY))
	return tokenString, err
}
